package com.yixun.qfbao.hander;

import com.yixun.qfbao.api.service.PersonnelService;
import com.yixun.qfbao.apidto.RegisterPartnerReqDto;
import com.yixun.qfbao.apidto.RegisterPartnerResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.vo.RegisterPartnerReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description
 * @Date 2017/11/25
 * @Author sangtao
 * @Computer Administrator
 */
@Service("registerPartnerHander")
public class RegisterPartnerHander extends CommonAbstractHander {
    private static Logger logger= LoggerFactory.getLogger(RegisterPartnerHander.class);
    @Autowired
    PersonnelService personnelService;
    @Override
    public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
        RegisterPartnerReqVo req = (RegisterPartnerReqVo)reqDto;
        RegisterPartnerReqDto registerPartnerReqDto = req.getParams();
        BaseResponseDTO<RegisterPartnerResDto> res = new BaseResponseDTO<RegisterPartnerResDto>();
        RegisterPartnerResDto resDto = new RegisterPartnerResDto();
        try {
            resDto = personnelService.registerPartner(registerPartnerReqDto);
            resDto.setResult(ResultEnum.SUCCESS.getNo());
            resDto.setResultMsg(resDto.getResultMsg());
        } catch (Exception e) {
            logger.error("RegisterPartnerHander error: {}", e);
            resDto.setResult(ResultEnum.FAIL.getNo());
            resDto.setResultMsg("注册失败");
        }
        res.setResData(resDto);
        res.setResult(resDto.getResult());
        return res;
    }
}
